package com.example.mybatis_plus;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.mybatis_plus.mapper.UserMapper;
import com.example.mybatis_plus.model.User;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
public class UserTestPaging {
    @Autowired
    private UserMapper userMapper;
    //分页查询
    @Test
    public void testPaging(){
        Page<User> page = new Page<>(3,3);
        userMapper.selectPage(page,null);
        //打印 Page 中的记录
        System.out.println(page.getRecords());
        System.out.println(page.getPages());
        System.out.println(page.getTotal());
        System.out.println(page.hasPrevious());
        System.out.println(page.hasNext());
    }
    @Test
    public void testMyPage(){
        Page<User> page = new Page<>(3,3);
        userMapper.selectMyPage(page,5);
        System.out.println(page.getRecords());
    }
}
